﻿using System.Net;
using System.Runtime.Serialization;

namespace Toybox.NicoSharp.Seiga
{
	using Extensions;
	using Utilities;

	partial class Book
	{

		#region [Static]

		public static ServiceStatus GetServiceStatus(CookieCollection cookies = null)
		{
			cookies = cookies.Coerce();

			string url = NicoUrls.BookApi + "service/status";
			string json = NicoWebClient.Get(url, cookies);
			return Deserializer.JsonDeserializer<ServiceStatus>(json);
		}

		#endregion  [Static]

		[DataContract]
		public class ServiceStatus
		{
			[DataMember]
			public bool is_success;

			[DataMember]
			public Status status;
		}

		[DataContract]
		public class Status
		{
			[DataMember]
			public string drm_version;

			[DataMember]
			public string ios_version;

			[DataMember]
			public bool is_maintenance;

			[DataMember]
			public int timestamp;
		}
	}
}
